package com.handydata.antifraud.enums;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum RiskReturnEnum implements Comment {
    DECRYPT_DATA_ERROR("1001","解密失败"),
    CHECK_SIGN_ERROR("1002","验签失败"),
    DATA_FORMAT_ERROR("1003","数据格式错误"),
    ENCRYPT_DATA_ERROR("1030","加密失败"),
    INVALID_API_KEY("2001","无效的apiKey"),
    INVALID_MER_CODE("2002","无效的商户号"),
    INVALID_PROD_CODE("2003","无效的产品号"),
    PARSE_JSON_ERROR("2005","解析JSON失败"),
    RISK_SYSTEM_ERROR("5010","风控决策系统异常"),
    RISK_WS_ERROR("5011","第三方接口调用异常"),
    NO_ORDER_ERROR("6001","无此订单"),
    RISK_MODEL_IN_EXEC("6002","风控模型执行中"),
    DATA_EMPTY_ERROR("1020","数据为空"),
    SUCCESS("0000" ,"成功");
    private String code;
    private String text;

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getText() {
        return text;
    }

    public static RiskReturnEnum of(String code) {
        for(RiskReturnEnum eu : values()) {
            if(eu.getCode().equals(code)) {
                return eu;
            }
        }
        return null;
    }

    /**
     * @see java.lang.Enum#toString()
     */
    @Override
    public String toString() {
        return code + "|" + text;
    }
}
